//
//  PropertyRentTableViewCell.m
//  PropertyManager
//
//  Created by TNG on 2018/7/17.
//  Copyright © 2018年 Tng. All rights reserved.
//

#import "PropertyRentTableViewCell.h"

@implementation PropertyRentTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self creatUI];
        self.separatorInset = UIEdgeInsetsMake(0, 15, 0, 0);
    }
    return self;
}

-(void)creatUI{
    [self.contentView addSubview:self.img];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.detailLabel];
    [self.contentView addSubview:self.moneyLabel];
}

-(void)send
{
    self.img.backgroundColor = SFMRandColor;
    self.titleLabel.text = @"我是标题七个字";
    self.detailLabel.text = @"24㎡｜广州 天河区 车陂｜办公";
    self.moneyLabel.text = @"￥4000/月";
}

-(void)sendRentModel:(RentModel *)model
{
    WeakSelf;
    [self.img sd_setImageWithURL:[NSURL URLWithString:model.minpic] placeholderImage:nil completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        weakSelf.img.image = image;
    }];
    
    self.titleLabel.text = model.title;
    NSMutableString * str = [NSMutableString string];
    if (![[NSString stringWithFormat:@"%@",model.housesize] isEqualToString:@""]) {
        [str appendString:[NSString stringWithFormat:@"%@ ",[NSString stringWithFormat:@"%@",model.housesize]]];
    }
    
    if (![model.estate isEqualToString:@""]) {
        [str appendString:[NSString stringWithFormat:@"%@ ",model.estate]];
    }
    
    if (![model.livec isEqualToString:@""]) {
        [str appendString:[NSString stringWithFormat:@"%@",model.livec]];
    }
    
    self.detailLabel.text = str;
    self.moneyLabel.text = [NSString stringWithFormat:@"￥%@/月",model.price];
}

-(UIImageView *)img
{
    if (_img == nil) {
        _img = [[UIImageView alloc] initWithFrame:CGRectMake(15, 16, 110, 67)];
        _img.contentMode = UIViewContentModeScaleAspectFill;
        _img.clipsToBounds = YES;
    }
    return _img;
}

-(UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(135, 15, WIDTH - 145, 20)];
        _titleLabel.font = font(16);
        _titleLabel.textColor = SFM51;
        _titleLabel.textAlignment = NSTextAlignmentLeft;
        _titleLabel.numberOfLines = 2;
    }
    return _titleLabel;
}

-(UILabel *)detailLabel
{
    if (_detailLabel == nil) {
        _detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(135, 42, WIDTH - 145, 17)];
        _detailLabel.font = font(12);
        _detailLabel.textColor = SFM153;
        _detailLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _detailLabel;
}

-(UILabel *)moneyLabel
{
    if (_moneyLabel == nil) {
        _moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(133, 67, WIDTH - 143, 20)];
        _moneyLabel.font = font(16);
        _moneyLabel.textColor = SFMColor(254, 39.8, 39.8);
        _moneyLabel.textAlignment = NSTextAlignmentLeft;
    }
    return _moneyLabel;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
